﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class ProcessDef : IAccessible<P_ProcessDef, ProcessDef>, ILogicEntity<P_ProcessDef, ProcessDef>
    {
        public int ID { get; set; }
        public string ProcessDefName { get; set; }
        public string XmlUrl { get; set; }
        public ProcessType ProcessType { get; set; }
        public ItemStatus Status { get; set; }
        public DateTime CreateTime { get; set; }
        public string CreateUser { get; set; }

        protected override void Covariant(P_ProcessDef model)
        {
            if (model != null)
            {
                this.CreateTime = model.CreateTime;
                this.CreateUser = model.CreateUser;
                this.ID = model.ID;
                this.ProcessDefName = model.ProcessDefName;
                this.ProcessType = (ProcessType)model.ProcessType;
                this.XmlUrl = model.XmlUrl;
                this.Status = (ItemStatus)model.Status;
            }
        }

        protected override P_ProcessDef Inverter(ProcessDef model)
        {
            if (model != null)
            {
                return new P_ProcessDef()
                {
                    CreateTime = model.CreateTime,
                    CreateUser = model.CreateUser,
                    ID = model.ID,
                    ProcessDefName = model.ProcessDefName,
                    ProcessType = (int)model.ProcessType,
                    XmlUrl = model.XmlUrl,
                    Status = (int)model.Status
                };
            }
            return null;
        }

        public ProcessDef Set(P_ProcessDef dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
